home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Metrowerks Versions / C04 Speech / P02 Wait Speech / WaitSpeech.c next >
Encoding:
Text File  |  1995-08-30  |  2.1 KB  |  95 lines  |  [TEXT/MMCC]

  1. //____________________________________________________________
  2. //    WaitSpeech.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Gestalt.h>
  13. #include <Speech.h>
  14.  
  15.  
  16. //____________________________________________________________
  17.  
  18. void     InitializeToolbox( void );
  19. Boolean  IsSpeechAvailable( void );
  20.  
  21.  
  22. //____________________________________________________________
  23.  
  24. void  main( void )
  25.    Str255   theString = "\pThis is the second string";
  26.    OSErr    theError;
  27.    Boolean  speechPresent;
  28.    
  29.    InitializeToolbox();
  30.  
  31.    speechPresent = IsSpeechAvailable();
  32.    if ( speechPresent == false )
  33.       ExitToShell();
  34.  
  35.    theError = SpeakString( "\pThis is string #1" );
  36.    if ( theError != noErr )
  37.       ExitToShell();
  38.  
  39.    while ( SpeechBusy() == true )
  40.       ;
  41.       
  42.    theError = SpeakString( theString );
  43.    if ( theError != noErr )
  44.       ExitToShell();
  45.       
  46.    // ** if you don't hear the second string of speech on your Mac,     **
  47.    // ** uncomment the following two lines and recompile. Some Macs     **
  48.    // ** exit before speech completes, some don't. In your apps, you'll **
  49.    // ** want to include the following lines after each call to         **
  50.    // ** to SpeakString() to ensure that speech completes.              **
  51.    
  52. //   while ( SpeechBusy() == true )
  53. //      ;
  54.  
  55. }
  56.  
  57.  
  58. //____________________________________________________________
  59.  
  60. Boolean  IsSpeechAvailable( void )
  61. {
  62.    OSErr    theError;
  63.    long     theResult;
  64.    Boolean  speechAvail;
  65.    
  66.    theError = Gestalt( gestaltSpeechAttr, &theResult );
  67.    if ( theError != noErr )
  68.       ExitToShell();
  69.       
  70.    speechAvail = theResult & ( 1 << gestaltSpeechMgrPresent );  
  71.    if ( speechAvail > 0 )
  72.       return ( true );
  73.    else
  74.       return ( false );
  75. }
  76.  
  77.  
  78. //____________________________________________________________
  79.  
  80. void  InitializeToolbox( void )
  81. {
  82.    InitGraf( &qd.thePort );
  83.    InitFonts();
  84.    InitWindows();
  85.    InitMenus();
  86.    TEInit();
  87.    InitDialogs( 0L );
  88.    FlushEvents( everyEvent, 0 );
  89.    InitCursor();
  90. }
  91.  
  92.  
  93.  
  94.